Makefile: Make all builds explicitly fully static (disable CGO)#3466
Makefile: Make all builds explicitly fully static (disable CGO)#3466JoeKar merged 6 commits intomicro-editor:masterfrom
Conversation
|
Shouldn't we just set |
|
Hm, exactly this was my intention in the first place to keep the capability to link it dynamically. |
3b296b1 to
8fcaa38
Compare
tools/cross-compile.sh
Outdated
| echo "Linux 64 fully static" | ||
| CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build | ||
| echo "Linux 64 fully static (deprecated)" | ||
| # Only kept for https://github.com/benweissmann/getmic.ro/blob/f90870e948afab8be9ec40884050044b59ed5b7c/index.sh#L197-L204 |
There was a problem hiding this comment.
Shouldn't we rather ask @benweissmann to update the script?
There was a problem hiding this comment.
I directly provided the PR: benweissmann/getmic.ro#40
But we've to keep in mind, that this will take effect earliest with the upcoming release.
There was a problem hiding this comment.
But we've to keep in mind, that this will take effect earliest with the upcoming release.
Sh*t... so this means that if we remove linux64-static and merge benweissmann/getmic.ro#40, getmic.ro will be broken for Musl until the next release?
There was a problem hiding this comment.
I would suggest doing one release where you publish statically-linked binaries using both the old name and new name (i.e., have the same statically linked binary published both with and without the -static suffix). Then, I can update getmic.ro after that release is published to cut over to the new name seamlessly, and future releases can drop the -static suffix.
8fcaa38 to
e44f6a2
Compare
Makefile
Outdated
| CGO_ENABLED=0 go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro | ||
|
|
||
| build-dynamic: generate | ||
| CGO_ENABLED=1 go build -trimpath -ldflags "-s -w $(GOVARS) $(ADDITIONAL_GO_LINKER_FLAGS)" ./cmd/micro |
There was a problem hiding this comment.
Seems a bit messy, and "asymmetric" (no quick version of build-dynamic, no dynamic version of build-dbg). Maybe instead of adding a target, just add a variable, e.g. DYNAMIC? I.e. just:
build-quick:
CGO_ENABLED=$(DYNAMIC) go build ...
build-dbg:
CGO_ENABLED=$(DYNAMIC) go build ...
And then we can run DYNAMIC=1 make build or whatever.
Also need to update (i.e. rewrite) the Fully static binary section in README.
There was a problem hiding this comment.
Damn, this "hidden" darwin dependency tools/info-plist.go 🤦♂️
So we've to exclude darwin somehow or can't generalize it in the Makefile.
Maybe define ADDITIONAL_GO_LINKER_FLAGS to be empty and extend it only in case the GOOS is darwin and forcing CGO_ENABLED to be 1 afterwards. 🤔
There was a problem hiding this comment.
Yeah, my first thought was: what the hell is this plist and can we just get rid of it or its -linkmode external. But it is not obvious if it is possible and how, and I have no wish to figure that out.
Maybe define
ADDITIONAL_GO_LINKER_FLAGSto be empty and extend it only in case theGOOSisdarwinand forcingCGO_ENABLEDto be1afterwards. 🤔
Seems to make sense.
There was a problem hiding this comment.
Maybe define
ADDITIONAL_GO_LINKER_FLAGSto be empty and extend it only in case theGOOSisdarwinand forcingCGO_ENABLEDto be1afterwards. 🤔
Should do the trick (for) now.
But to be honest, this kind of meta info is only included in the moment micro is natively build on macOS. It's completely missing, at least since the builds are cross compiled via GitHub actions, in our prebuilt binaries. 🤷♂️
There was a problem hiding this comment.
Yeah, I've just realized that, after looking at GOHOSTOS in your patch.
Which makes this feature from #513 even more... interesting.
There was a problem hiding this comment.
Although before 6945aa3 this feature was used for cross-compiled binaries as well... but I doubt it was really working correctly.
There was a problem hiding this comment.
Now, should we document this (the fact that MacOS builds are an exception, but only native ones) in README as well?
There was a problem hiding this comment.
Yep, better to document before someone is complaining.
Although before 6945aa3 this feature was used for cross-compiled binaries as well... but I doubt it was really working correctly.
Me too, since building micro with darwin AND CGO_ENABLED=1 requires clang.
We could try it with GOOS instead of GOHOSTOS as switch, but then we most probably run into trouble cross compiling for darwin where clang is not available. This might hit the GitHub actions etc.pp
This will keep the symbol table and the DWARF information.
…x 64" It is kept for the next release only to support... https://github.com/benweissmann/getmic.ro/blob/f90870e948afab8be9ec40884050044b59ed5b7c/index.sh#L197-L204 ...and allow a fluent switch via: benweissmann/getmic.ro#40
58033b8 to
8257bde
Compare
8257bde to
3f1e5ea
Compare
Due to this the "Linux 64 fully static" has been marked deprecated and is only kept for compatibility with:
https://github.com/benweissmann/getmic.ro/blob/f90870e948afab8be9ec40884050044b59ed5b7c/index.sh#L197-L204
Fixes #3463